package com.ricks.contoller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.dialect.Sqlite3Dialect;
import com.ricks.model.User;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

// 以下用法为 controller 配置了 viewPath
public class AdminController extends Controller {

    private static User dao = new User().dao();

    public void index() {
        setAttr("welcome", "欢迎进入游戏后台管理系统");
        setAttr("serverTime", new Date());

        // 模拟一些游戏数据
        List<String> serverList = Arrays.asList("服务器A", "服务器B", "服务器C");
        setAttr("serverList", serverList);

        // 渲染模板，对应 src/main/webapp/index.html


        User user = new User(1, "ricks", "123456");
        user.save();
        render("admin.html");
    }
}
